package com.ruoyi.cases.utils.excel;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 复杂Excel举例
 */
public class HssfExcel {

    /**
     * 主方法
     *
     * @param args     args
     * @param request  request
     * @param response response
     */
    public static void main(String[] args, HttpServletRequest request,
        HttpServletResponse response) {
        try {
            Map model = new HashMap();
            String[][] upNoFrame = new String[1][4];
            String[] up = new String[]{"1", "0&3", "测试&你好", "1,1,0,2&1,1,3,5"};
            upNoFrame[0] = up;
            model.put("fileName", "Etc超时查询数据统计");
            model.put("excelTitle", "Etc超时查询数据统计");
            model.put("excelTitleClos", 5);
            //[[行号,列号(&分隔),文字(&分隔),合并单元格(起始行,结束行,起始列,结束列)]]
            model.put("upNoFrame", upNoFrame);
            model.put("titleStarRows", 2);
            model.put("titleRows", 4);
            model.put("titles2", new String[]{"时间       1", "科目", "科目", "科目", "科目", "备注"});
            model.put("titles3", new String[]{"时间", "科目一", "科目二", "科目三", "科目四", "备注"});
            model.put("handClum", new String[]{"2,3,0,0", "2,2,1,4", "2,3,5,5"});
            model.put("names", "createDate,ke1,ke2,ke3,ke4,remark".split(","));
            List<Map> list = new ArrayList<>();
            for (int i = 0; i < 5; i++) {
                Map kemu = new HashMap();
                kemu.put("createDate", "2018/11/06");
                kemu.put("ke1", "理论" + i);
                kemu.put("ke2", "理论" + i);
                kemu.put("ke3", "理论" + i);
                kemu.put("ke4", "理论" + i);
                kemu.put("remark", "remark");
                list.add(kemu);
            }
            model.put("list", list);
            new ExcelExportToFileUrlComplex().buildExcelDocument(model, request, response);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
